# -*- coding: utf-8 -*- 
# @Time : 2021/4/3 16:28 
# @Author : Dong 
# @File : bibi_taobao_maintain.py

from selenium import webdriver
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import constant

chrome_option = webdriver.ChromeOptions()
chrome_option.add_experimental_option('excludeSwitches', ['enable-automation'])  # 以开发者模式

browser = webdriver.Chrome(options=chrome_option)


class taobao_infos:
    # 初始化构造函数
    def __init__(self,url):
        self.url = url
        self.browesr = browser
        self.wait = WebDriverWait(self.browesr,10)

    def login(self):
        self.browesr.get(self.url)
        # 微博登陆
        if self.browesr.find_element_by_css_selector('#login-form > div.login-blocks.sns-login-links > a.weibo-login'):
            self.browesr.find_element_by_css_selector('#login-form > div.login-blocks.sns-login-links > a.weibo-login').click()
        else:
            return '获取微博失败'

        # 获取微博的框 ‘#pl_login_logged > div > div:nth-child(2) > div > input’
        if self.browesr.find_element_by_css_selector('#pl_login_logged > div > div:nth-child(2) > div > input'):
            weibo_user = self.browesr.find_element_by_css_selector('#pl_login_logged > div > div:nth-child(2) > div > input')
            weibo_user.send_keys()

if __name__ == '__main__':
    T = taobao_infos(constant.url)
    T.login()